class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: D = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: C = None
        self.x: E = None
        self.t: C = None
        self.txt = txt

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

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

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

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

c.q = e
c.w = d
c.x = d
l.q = c
l.s = g
l.x = e
l.t = b
g.z = e
g.p = e
g.y = l
g.s = d
d.x = g
e.t = l
b.z = e
b.p = e
b.y = l
b.s = d
assert b.s.x.s.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.w: D = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: A = None
        self.s: C = None
        self.x: E = None
        self.t: C = None
        self.txt = txt

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

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

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

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

c.q = e
c.w = d
c.x = d
l.q = c
l.s = g
l.x = e
l.t = b
g.z = e
g.p = e
g.y = l
g.s = d
d.x = g
e.t = l
b.z = e
b.p = e
b.y = l
b.s = d
assert b.s.x.s.txt == "d"