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

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: B = None
        self.r: D = None
        self.z: B = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
c = C("c")
e = D("e")
g = E("g")
d = B("d")

k.t = c
b.p = k
b.r = e
b.o = e
c.q = g
c.y = d
c.r = e
c.z = b
e.x = c
e.r = b
e.t = d
g.s = b
d.p = k
d.r = e
d.o = e
assert e.r.o.t.o.x.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.q: E = None
        self.y: B = None
        self.r: D = None
        self.z: B = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
c = C("c")
e = D("e")
g = E("g")
d = B("d")

k.t = c
b.p = k
b.r = e
b.o = e
c.q = g
c.y = d
c.r = e
c.z = b
e.x = c
e.r = b
e.t = d
g.s = b
d.p = k
d.r = e
d.o = e
assert e.r.o.t.o.x.z.txt == "b"