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

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: A = None
        self.txt = txt

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

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

h = A("h")
l = B("l")
c = C("c")
j = D("j")
n = B("n")
d = B("d")

h.q = c
l.y = h
l.z = h
c.u = j
c.t = j
j.t = d
j.w = l
n.y = h
n.z = h
d.y = h
d.z = h
assert n.y.q.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.y: A = None
        self.z: A = None
        self.txt = txt

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

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

h = A("h")
l = B("l")
c = C("c")
j = D("j")
n = B("n")
d = B("d")

h.q = c
l.y = h
l.z = h
c.u = j
c.t = j
j.t = d
j.w = l
n.y = h
n.z = h
d.y = h
d.z = h
assert n.y.q.u.t.txt == "d"