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

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

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

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

m = A("m")
k = B("k")
g = C("g")
i = D("i")
d = D("d")
f = A("f")
n = A("n")

m.u = k
m.r = k
m.x = d
k.o = d
g.x = d
g.v = n
i.t = m
d.t = n
f.u = k
f.r = k
f.x = i
n.u = k
n.r = k
n.x = i
assert m.x.t.x.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.x: D = None
        self.r: B = None
        self.txt = txt

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

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

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

m = A("m")
k = B("k")
g = C("g")
i = D("i")
d = D("d")
f = A("f")
n = A("n")

m.u = k
m.r = k
m.x = d
k.o = d
g.x = d
g.v = n
i.t = m
d.t = n
f.u = k
f.r = k
f.x = i
n.u = k
n.r = k
n.x = i
assert m.x.t.x.t.txt == "m"