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

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

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

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

f = A("f")
h = B("h")
d = C("d")
m = D("m")
c = B("c")
k = C("k")
e = B("e")

f.r = d
f.v = m
f.s = e
h.q = k
h.t = e
h.z = m
d.x = m
d.y = h
d.p = k
m.r = f
c.q = d
c.t = e
c.z = m
k.x = m
k.y = h
k.p = d
e.q = k
e.t = h
e.z = m
assert e.t.t.t.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: C = None
        self.v: D = None
        self.s: B = None
        self.txt = txt

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

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

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

f = A("f")
h = B("h")
d = C("d")
m = D("m")
c = B("c")
k = C("k")
e = B("e")

f.r = d
f.v = m
f.s = e
h.q = k
h.t = e
h.z = m
d.x = m
d.y = h
d.p = k
m.r = f
c.q = d
c.t = e
c.z = m
k.x = m
k.y = h
k.p = d
e.q = k
e.t = h
e.z = m
assert e.t.t.t.z.txt == "m"