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

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
k = C("k")
i = D("i")
b = A("b")
j = C("j")
h = D("h")

c.r = b
c.t = h
c.p = e
c.x = i
e.z = j
k.t = c
i.s = h
b.r = c
b.t = i
b.x = i
b.p = e
j.t = b
h.s = i
assert i.s.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.r: A = None
        self.t: D = None
        self.p: B = None
        self.x: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.z: C = None
        self.txt = txt

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

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

c = A("c")
e = B("e")
k = C("k")
i = D("i")
b = A("b")
j = C("j")
h = D("h")

c.r = b
c.t = h
c.p = e
c.x = i
e.z = j
k.t = c
i.s = h
b.r = c
b.t = i
b.x = i
b.p = e
j.t = b
h.s = i
assert i.s.s.s.txt == "h"