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

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
a = C("a")
d = D("d")
b = E("b")
i = E("i")
l = D("l")

g.z = b
f.t = g
f.o = d
f.r = a
a.q = g
a.z = f
d.u = f
d.r = f
d.o = b
b.y = i
i.y = b
l.u = f
l.r = f
l.o = i
assert a.q.z.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.z: B = None
        self.txt = txt

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

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

g = A("g")
f = B("f")
a = C("a")
d = D("d")
b = E("b")
i = E("i")
l = D("l")

g.z = b
f.t = g
f.o = d
f.r = a
a.q = g
a.z = f
d.u = f
d.r = f
d.o = b
b.y = i
i.y = b
l.u = f
l.r = f
l.o = i
assert a.q.z.y.y.y.y.txt == "b"