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

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

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

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

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

c.t = a
c.p = a
b.t = a
b.o = i
a.r = i
a.t = c
a.w = b
a.s = b
i.q = c
assert i.q.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: C = None
        self.txt = txt

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

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

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

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

c.t = a
c.p = a
b.t = a
b.o = i
a.r = i
a.t = c
a.w = b
a.s = b
i.q = c
assert i.q.p.t.txt == "c"