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

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

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

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

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

a.s = g
a.u = l
a.z = l
b.t = a
c.p = g
i.z = l
i.s = g
g.p = c
l.t = a
assert b.t.s.p.p.txt == "
class A:
    def __init__(self, txt: str):
        self.s: C = None
        self.u: B = None
        self.z: B = None
        self.txt = txt

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

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

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

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

a.s = g
a.u = l
a.z = l
b.t = a
c.p = g
i.z = l
i.s = g
g.p = c
l.t = a
assert b.t.s.p.p.txt == "g"