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

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

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

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

d = A("d")
j = B("j")
h = C("h")
b = D("b")
e = A("e")
f = C("f")
m = D("m")
i = A("i")
g = A("g")
l = A("l")

d.x = b
d.u = i
j.p = f
j.t = f
j.u = f
j.v = g
h.r = b
b.t = h
b.o = m
e.x = m
e.u = i
f.r = m
m.t = h
m.o = b
i.x = b
i.u = d
g.x = m
g.u = e
l.x = b
l.u = e
assert i.x.o.t.r.o.t.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.u: A = None
        self.txt = txt

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

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

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

d = A("d")
j = B("j")
h = C("h")
b = D("b")
e = A("e")
f = C("f")
m = D("m")
i = A("i")
g = A("g")
l = A("l")

d.x = b
d.u = i
j.p = f
j.t = f
j.u = f
j.v = g
h.r = b
b.t = h
b.o = m
e.x = m
e.u = i
f.r = m
m.t = h
m.o = b
i.x = b
i.u = d
g.x = m
g.u = e
l.x = b
l.u = e
assert i.x.o.t.r.o.t.r.o.txt == "m"