class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: C = None
        self.txt = txt

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

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

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

f = A("f")
i = B("i")
l = C("l")
a = D("a")
j = D("j")
m = C("m")
k = A("k")

f.r = j
f.x = m
i.o = m
i.v = a
i.u = j
l.p = i
a.z = i
a.v = k
a.x = l
j.z = i
j.v = k
j.x = m
m.p = i
k.r = j
k.x = l
assert f.x.p.v.z.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.x: C = None
        self.txt = txt

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

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

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

f = A("f")
i = B("i")
l = C("l")
a = D("a")
j = D("j")
m = C("m")
k = A("k")

f.r = j
f.x = m
i.o = m
i.v = a
i.u = j
l.p = i
a.z = i
a.v = k
a.x = l
j.z = i
j.v = k
j.x = m
m.p = i
k.r = j
k.x = l
assert f.x.p.v.z.txt == "i"