class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: E = None
        self.w: E = None
        self.r: A = None
        self.txt = txt

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

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

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

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

d = A("d")
h = B("h")
l = C("l")
k = D("k")
e = E("e")
c = B("c")
f = E("f")
b = A("b")

d.x = h
d.p = e
d.w = f
d.r = b
h.x = k
l.w = b
l.q = b
l.y = c
l.u = f
l.z = d
k.x = d
k.z = f
k.t = l
e.p = d
c.x = k
f.p = d
b.x = h
b.p = e
b.w = f
b.r = d
assert c.x.x.x.x.t.z.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.p: E = None
        self.w: E = None
        self.r: A = None
        self.txt = txt

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

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

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

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

d = A("d")
h = B("h")
l = C("l")
k = D("k")
e = E("e")
c = B("c")
f = E("f")
b = A("b")

d.x = h
d.p = e
d.w = f
d.r = b
h.x = k
l.w = b
l.q = b
l.y = c
l.u = f
l.z = d
k.x = d
k.z = f
k.t = l
e.p = d
c.x = k
f.p = d
b.x = h
b.p = e
b.w = f
b.r = d
assert c.x.x.x.x.t.z.r.p.txt == "e"