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

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

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

d.t = h
d.v = h
k.o = d
k.u = f
h.v = k
i.p = k
m.t = l
m.v = l
f.p = k
j.v = k
l.v = k
assert h.v.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.v: C = None
        self.txt = txt

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

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

d.t = h
d.v = h
k.o = d
k.u = f
h.v = k
i.p = k
m.t = l
m.v = l
f.p = k
j.v = k
l.v = k
assert h.v.u.p.txt == "k"