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

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

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

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

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

f.p = d
f.x = d
f.u = m
f.v = j
c.u = j
k.v = d
m.z = b
j.u = i
n.z = c
b.u = c
e.z = i
i.u = j
d.p = f
d.x = f
d.u = e
d.v = b
assert k.v.x.v.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.p: A = None
        self.x: A = None
        self.u: D = None
        self.v: B = None
        self.txt = txt

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

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

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

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

f.p = d
f.x = d
f.u = m
f.v = j
c.u = j
k.v = d
m.z = b
j.u = i
n.z = c
b.u = c
e.z = i
i.u = j
d.p = f
d.x = f
d.u = e
d.v = b
assert k.v.x.v.u.u.u.u.u.u.txt == "j"