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

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

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

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

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

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

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

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

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

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

k.v = j
k.o = h
h.o = f
h.u = j
h.r = b
h.p = k
i.v = b
b.v = j
b.p = m
f.v = m
a.v = f
a.o = h
m.v = i
m.p = b
j.v = b
assert k.v.v.p.p.v.v.txt == "b"