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

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

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

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

h = A("h")
j = B("j")
m = C("m")
e = D("e")
k = C("k")
a = B("a")

h.r = e
h.t = e
j.q = h
j.t = a
m.z = h
m.t = k
m.w = e
e.z = j
e.r = j
e.o = j
k.z = h
k.t = m
k.w = e
a.q = h
a.t = j
assert h.r.r.q.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.t: D = None
        self.txt = txt

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

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

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

h = A("h")
j = B("j")
m = C("m")
e = D("e")
k = C("k")
a = B("a")

h.r = e
h.t = e
j.q = h
j.t = a
m.z = h
m.t = k
m.w = e
e.z = j
e.r = j
e.o = j
k.z = h
k.t = m
k.w = e
a.q = h
a.t = j
assert h.r.r.q.txt == "h"