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

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

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

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

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

a.t = m
b.t = n
b.v = k
k.p = g
k.v = a
k.u = a
k.o = d
n.v = a
n.s = d
m.p = k
m.v = a
m.u = a
m.o = d
d.v = a
d.s = n
g.p = k
g.v = a
g.u = a
g.o = d
assert a.t.p.u.t.p.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.txt = txt

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

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

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

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

a.t = m
b.t = n
b.v = k
k.p = g
k.v = a
k.u = a
k.o = d
n.v = a
n.s = d
m.p = k
m.v = a
m.u = a
m.o = d
d.v = a
d.s = n
g.p = k
g.v = a
g.u = a
g.o = d
assert a.t.p.u.t.p.u.t.txt == "m"