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

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

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

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

h = A("h")
g = B("g")
e = C("e")
n = D("n")
l = B("l")
b = D("b")
j = C("j")

h.u = b
g.q = b
e.t = g
e.u = h
e.s = h
n.v = e
n.u = h
n.z = b
l.q = n
b.v = j
b.u = h
b.z = n
j.t = g
j.u = h
j.s = h
assert j.u.u.v.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: D = None
        self.txt = txt

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

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

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

h = A("h")
g = B("g")
e = C("e")
n = D("n")
l = B("l")
b = D("b")
j = C("j")

h.u = b
g.q = b
e.t = g
e.u = h
e.s = h
n.v = e
n.u = h
n.z = b
l.q = n
b.v = j
b.u = h
b.z = n
j.t = g
j.u = h
j.s = h
assert j.u.u.v.t.txt == "g"