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

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

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

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

h = A("h")
m = B("m")
j = C("j")
f = D("f")
l = A("l")
e = D("e")
g = D("g")

h.u = j
h.x = j
h.z = j
h.t = m
m.x = l
m.t = l
m.q = f
m.z = j
j.z = h
f.o = m
f.t = j
l.u = j
l.x = j
l.z = j
l.t = m
e.o = m
e.t = j
g.o = m
g.t = j
assert f.t.z.t.q.o.q.o.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.x: C = None
        self.t: B = None
        self.z: C = None
        self.txt = txt

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

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

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

h = A("h")
m = B("m")
j = C("j")
f = D("f")
l = A("l")
e = D("e")
g = D("g")

h.u = j
h.x = j
h.z = j
h.t = m
m.x = l
m.t = l
m.q = f
m.z = j
j.z = h
f.o = m
f.t = j
l.u = j
l.x = j
l.z = j
l.t = m
e.o = m
e.t = j
g.o = m
g.t = j
assert f.t.z.t.q.o.q.o.txt == "m"