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

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

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

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

h = A("h")
a = B("a")
b = C("b")
e = D("e")
n = B("n")
d = A("d")
c = C("c")
f = A("f")
k = D("k")

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

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

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

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

h = A("h")
a = B("a")
b = C("b")
e = D("e")
n = B("n")
d = A("d")
c = C("c")
f = A("f")
k = D("k")

h.z = c
h.p = c
a.v = k
a.q = h
b.u = c
b.o = c
e.w = f
n.v = k
n.q = f
d.z = c
d.p = c
c.u = b
c.o = b
f.z = b
f.p = c
k.w = d
assert f.p.u.o.u.o.o.u.u.o.txt == "c"