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

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: A = None
        self.y: A = None
        self.r: B = None
        self.u: B = None
        self.txt = txt

b = A("b")
n = B("n")
f = C("f")
m = D("m")
e = E("e")
h = D("h")
a = C("a")

b.x = f
b.y = f
b.q = n
b.r = e
n.x = f
f.r = a
f.v = b
m.x = n
m.t = n
m.s = b
m.z = f
e.x = h
e.q = b
e.y = b
e.r = n
e.u = n
h.x = n
h.t = n
h.s = b
h.z = a
a.r = f
a.v = b
assert b.r.y.q.x.v.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: C = None
        self.q: B = None
        self.y: C = None
        self.r: E = None
        self.txt = txt

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

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

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

class E:
    def __init__(self, txt: str):
        self.x: D = None
        self.q: A = None
        self.y: A = None
        self.r: B = None
        self.u: B = None
        self.txt = txt

b = A("b")
n = B("n")
f = C("f")
m = D("m")
e = E("e")
h = D("h")
a = C("a")

b.x = f
b.y = f
b.q = n
b.r = e
n.x = f
f.r = a
f.v = b
m.x = n
m.t = n
m.s = b
m.z = f
e.x = h
e.q = b
e.y = b
e.r = n
e.u = n
h.x = n
h.t = n
h.s = b
h.z = a
a.r = f
a.v = b
assert b.r.y.q.x.v.x.txt == "f"