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

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

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

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

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

c.y = d
n.x = i
n.y = i
g.o = a
g.x = a
a.s = n
a.u = n
a.t = g
i.y = d
d.s = n
d.u = n
d.t = g
assert i.y.s.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.txt = txt

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

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

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

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

c.y = d
n.x = i
n.y = i
g.o = a
g.x = a
a.s = n
a.u = n
a.t = g
i.y = d
d.s = n
d.u = n
d.t = g
assert i.y.s.y.txt == "i"