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

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

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

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

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

c.t = d
c.p = e
c.o = e
c.s = g
g.u = i
g.p = d
g.r = c
d.s = c
d.o = c
d.u = g
d.x = i
i.u = e
i.z = g
i.w = g
i.t = d
e.u = i
e.z = g
e.w = g
e.t = d
assert g.p.u.u.u.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.p: D = None
        self.s: B = None
        self.o: D = None
        self.txt = txt

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

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

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

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

c.t = d
c.p = e
c.o = e
c.s = g
g.u = i
g.p = d
g.r = c
d.s = c
d.o = c
d.u = g
d.x = i
i.u = e
i.z = g
i.w = g
i.t = d
e.u = i
e.z = g
e.w = g
e.t = d
assert g.p.u.u.u.txt == "e"