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

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

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

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

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

a.x = c
a.y = c
a.s = g
n.t = d
n.u = c
n.x = g
n.o = g
g.p = n
b.r = d
b.w = g
b.x = c
d.t = n
d.u = c
d.x = g
d.o = g
c.x = a
c.y = a
c.s = g
assert c.x.s.p.o.p.t.txt == "
class A:
    def __init__(self, txt: str):
        self.x: A = None
        self.s: C = None
        self.y: A = None
        self.txt = txt

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

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

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

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

a.x = c
a.y = c
a.s = g
n.t = d
n.u = c
n.x = g
n.o = g
g.p = n
b.r = d
b.w = g
b.x = c
d.t = n
d.u = c
d.x = g
d.o = g
c.x = a
c.y = a
c.s = g
assert c.x.s.p.o.p.t.txt == "d"