class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: C = None
        self.z: D = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
a = C("a")
e = D("e")
i = B("i")

g.x = e
g.z = e
g.y = a
c.t = g
c.p = a
a.x = g
e.t = i
e.o = g
e.x = g
i.t = g
i.p = a
assert i.t.x.x.y.txt == "
class A:
    def __init__(self, txt: str):
        self.x: D = None
        self.y: C = None
        self.z: D = None
        self.txt = txt

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

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

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

g = A("g")
c = B("c")
a = C("a")
e = D("e")
i = B("i")

g.x = e
g.z = e
g.y = a
c.t = g
c.p = a
a.x = g
e.t = i
e.o = g
e.x = g
i.t = g
i.p = a
assert i.t.x.x.y.txt == "a"