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

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

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

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

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

d.z = b
a.v = i
a.z = g
a.w = g
c.t = g
g.s = d
g.t = k
l.t = g
k.t = g
n.t = g
i.v = a
i.z = g
i.w = g
b.z = d
assert l.t.t.t.t.t.t.t.t.t.txt == "
class A:
    def __init__(self, txt: str):
        self.z: A = None
        self.txt = txt

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

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

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

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

d.z = b
a.v = i
a.z = g
a.w = g
c.t = g
g.s = d
g.t = k
l.t = g
k.t = g
n.t = g
i.v = a
i.z = g
i.w = g
b.z = d
assert l.t.t.t.t.t.t.t.t.t.txt == "g"