class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: A = None
        self.v: D = None
        self.t: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: E = None
        self.y: A = None
        self.q: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: D = None
        self.o: B = None
        self.txt = txt

c = A("c")
n = B("n")
l = C("l")
f = D("f")
j = E("j")
g = A("g")

c.z = g
c.r = g
n.u = c
n.t = c
n.o = g
n.v = f
l.v = f
l.y = j
f.t = l
f.o = j
f.y = g
f.q = c
j.u = f
j.o = n
g.z = c
g.r = c
assert f.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.r: A = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.u: A = None
        self.o: A = None
        self.v: D = None
        self.t: A = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.v: D = None
        self.y: E = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: E = None
        self.y: A = None
        self.q: A = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.u: D = None
        self.o: B = None
        self.txt = txt

c = A("c")
n = B("n")
l = C("l")
f = D("f")
j = E("j")
g = A("g")

c.z = g
c.r = g
n.u = c
n.t = c
n.o = g
n.v = f
l.v = f
l.y = j
f.t = l
f.o = j
f.y = g
f.q = c
j.u = f
j.o = n
g.z = c
g.r = c
assert f.o.o.o.txt == "g"