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

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

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

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

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

c.x = a
c.o = a
c.t = i
a.o = k
k.x = c
k.r = c
k.p = a
k.y = a
h.r = b
h.o = c
h.s = k
b.r = h
b.o = c
b.s = i
i.x = c
i.r = c
i.p = a
i.y = a
assert i.r.o.o.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.o: B = None
        self.t: C = None
        self.txt = txt

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

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

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

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

c.x = a
c.o = a
c.t = i
a.o = k
k.x = c
k.r = c
k.p = a
k.y = a
h.r = b
h.o = c
h.s = k
b.r = h
b.o = c
b.s = i
i.x = c
i.r = c
i.p = a
i.y = a
assert i.r.o.o.r.x.txt == "a"