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

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

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

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

i = A("i")
m = B("m")
d = C("d")
a = D("a")
b = B("b")
n = B("n")
f = D("f")
j = C("j")
e = A("e")
h = D("h")

i.z = e
i.y = e
i.t = e
i.x = j
m.u = f
m.o = a
m.x = a
d.x = j
d.q = j
a.p = e
a.z = i
a.o = j
a.u = d
b.u = f
b.x = f
b.o = a
n.u = h
n.o = a
n.x = f
f.p = i
f.z = e
f.o = j
f.u = j
j.x = d
j.q = d
e.z = i
e.y = i
e.t = i
e.x = j
h.p = e
h.z = i
h.o = j
h.u = d
assert j.x.q.q.q.x.x.q.x.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.x: C = None
        self.y: A = None
        self.t: A = None
        self.txt = txt

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

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

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

i = A("i")
m = B("m")
d = C("d")
a = D("a")
b = B("b")
n = B("n")
f = D("f")
j = C("j")
e = A("e")
h = D("h")

i.z = e
i.y = e
i.t = e
i.x = j
m.u = f
m.o = a
m.x = a
d.x = j
d.q = j
a.p = e
a.z = i
a.o = j
a.u = d
b.u = f
b.x = f
b.o = a
n.u = h
n.o = a
n.x = f
f.p = i
f.z = e
f.o = j
f.u = j
j.x = d
j.q = d
e.z = i
e.y = i
e.t = i
e.x = j
h.p = e
h.z = i
h.o = j
h.u = d
assert j.x.q.q.q.x.x.q.x.q.q.txt == "j"