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

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

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

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

a = A("a")
n = B("n")
d = C("d")
c = D("c")
f = A("f")
g = D("g")
e = B("e")
l = C("l")

a.y = l
n.v = f
n.t = f
n.z = e
d.o = l
c.v = g
c.s = f
c.z = a
f.y = l
g.v = c
g.s = f
g.z = f
e.v = a
e.t = a
e.z = n
l.o = d
assert g.z.y.o.o.o.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.txt = txt

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

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

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

a = A("a")
n = B("n")
d = C("d")
c = D("c")
f = A("f")
g = D("g")
e = B("e")
l = C("l")

a.y = l
n.v = f
n.t = f
n.z = e
d.o = l
c.v = g
c.s = f
c.z = a
f.y = l
g.v = c
g.s = f
g.z = f
e.v = a
e.t = a
e.z = n
l.o = d
assert g.z.y.o.o.o.o.o.txt == "d"