class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.z: A = None
        self.o: 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: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
b = C("b")
a = D("a")
i = A("i")
g = B("g")
m = D("m")

k.v = a
k.z = i
k.o = g
d.u = g
b.v = g
a.p = m
a.v = b
a.r = d
i.v = a
i.z = k
i.o = d
g.u = d
m.p = a
m.v = b
m.r = g
assert b.v.u.u.u.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.z: A = None
        self.o: 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: B = None
        self.txt = txt

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

k = A("k")
d = B("d")
b = C("b")
a = D("a")
i = A("i")
g = B("g")
m = D("m")

k.v = a
k.z = i
k.o = g
d.u = g
b.v = g
a.p = m
a.v = b
a.r = d
i.v = a
i.z = k
i.o = d
g.u = d
m.p = a
m.v = b
m.r = g
assert b.v.u.u.u.u.u.u.txt == "g"