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

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

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

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

i = A("i")
d = B("d")
c = C("c")
h = D("h")
l = A("l")
j = B("j")
k = C("k")
g = D("g")

i.t = d
d.p = k
d.r = i
d.o = c
c.r = l
c.p = k
h.t = l
h.p = d
l.t = j
j.p = k
j.o = k
j.r = l
k.r = l
k.p = c
g.t = i
g.p = d
assert d.o.r.t.r.t.o.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.txt = txt

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

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

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

i = A("i")
d = B("d")
c = C("c")
h = D("h")
l = A("l")
j = B("j")
k = C("k")
g = D("g")

i.t = d
d.p = k
d.r = i
d.o = c
c.r = l
c.p = k
h.t = l
h.p = d
l.t = j
j.p = k
j.o = k
j.r = l
k.r = l
k.p = c
g.t = i
g.p = d
assert d.o.r.t.r.t.o.txt == "k"