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

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

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

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

a = A("a")
b = B("b")
g = C("g")
m = D("m")
f = A("f")
e = C("e")
l = D("l")
k = A("k")
c = A("c")

a.z = k
b.u = e
b.v = k
g.p = b
g.z = l
m.t = c
m.s = l
f.z = c
e.p = b
e.z = m
l.t = c
l.s = m
k.z = f
c.z = k
assert g.z.s.s.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

a = A("a")
b = B("b")
g = C("g")
m = D("m")
f = A("f")
e = C("e")
l = D("l")
k = A("k")
c = A("c")

a.z = k
b.u = e
b.v = k
g.p = b
g.z = l
m.t = c
m.s = l
f.z = c
e.p = b
e.z = m
l.t = c
l.s = m
k.z = f
c.z = k
assert g.z.s.s.txt == "l"