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

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

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

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

g = A("g")
a = B("a")
m = C("m")
k = D("k")
j = A("j")

g.u = j
g.t = j
g.z = m
g.s = k
a.s = m
m.t = k
m.o = k
m.u = k
k.s = a
j.u = g
j.t = g
j.z = m
j.s = k
assert m.u.s.s.t.s.txt == "
class A:
    def __init__(self, txt: str):
        self.u: A = None
        self.z: C = None
        self.t: A = None
        self.s: D = None
        self.txt = txt

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

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

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

g = A("g")
a = B("a")
m = C("m")
k = D("k")
j = A("j")

g.u = j
g.t = j
g.z = m
g.s = k
a.s = m
m.t = k
m.o = k
m.u = k
k.s = a
j.u = g
j.t = g
j.z = m
j.s = k
assert m.u.s.s.t.s.txt == "a"