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

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

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

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

k = A("k")
i = B("i")
e = C("e")
j = D("j")
m = D("m")
f = D("f")

k.r = i
i.r = m
e.o = k
j.x = k
j.t = e
j.p = i
m.x = k
m.t = e
m.p = i
f.x = k
f.t = e
f.p = i
assert e.o.r.r.p.txt == "
class A:
    def __init__(self, txt: str):
        self.r: B = None
        self.txt = txt

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

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

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

k = A("k")
i = B("i")
e = C("e")
j = D("j")
m = D("m")
f = D("f")

k.r = i
i.r = m
e.o = k
j.x = k
j.t = e
j.p = i
m.x = k
m.t = e
m.p = i
f.x = k
f.t = e
f.p = i
assert e.o.r.r.p.txt == "i"