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

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

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

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

a = A("a")
l = B("l")
f = C("f")
j = D("j")
k = B("k")
d = A("d")
c = C("c")
b = C("b")
h = D("h")

a.z = j
a.p = c
a.q = d
l.r = h
l.o = h
l.v = f
f.q = h
f.v = b
f.z = b
j.u = k
j.q = d
k.r = j
k.o = j
k.v = f
d.z = j
d.p = c
d.q = a
c.q = j
c.v = b
c.z = f
b.q = h
b.v = c
b.z = f
h.u = l
h.q = a
assert c.z.q.q.z.q.p.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.z: D = None
        self.p: C = None
        self.q: A = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
f = C("f")
j = D("j")
k = B("k")
d = A("d")
c = C("c")
b = C("b")
h = D("h")

a.z = j
a.p = c
a.q = d
l.r = h
l.o = h
l.v = f
f.q = h
f.v = b
f.z = b
j.u = k
j.q = d
k.r = j
k.o = j
k.v = f
d.z = j
d.p = c
d.q = a
c.q = j
c.v = b
c.z = f
b.q = h
b.v = c
b.z = f
h.u = l
h.q = a
assert c.z.q.q.z.q.p.v.z.txt == "f"