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

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

a = A("a")
m = B("m")
k = C("k")
n = D("n")
f = A("f")
d = A("d")
e = D("e")

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

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

a = A("a")
m = B("m")
k = C("k")
n = D("n")
f = A("f")
d = A("d")
e = D("e")

a.o = d
a.s = m
a.r = k
m.u = e
m.t = d
k.v = e
n.x = k
f.o = a
f.s = m
f.r = k
d.o = a
d.s = m
d.r = k
e.x = k
assert n.x.v.x.txt == "k"