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

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

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

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

g = A("g")
n = B("n")
d = C("d")
j = D("j")
a = D("a")
e = A("e")
i = A("i")
b = B("b")
k = A("k")

g.o = d
g.v = b
n.w = b
n.r = d
n.z = d
d.z = n
j.x = n
a.x = n
e.o = d
e.v = n
i.o = d
i.v = b
b.w = n
b.r = d
b.z = d
k.o = d
k.v = b
assert e.v.r.z.w.w.z.z.r.z.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.v: B = None
        self.txt = txt

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

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

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

g = A("g")
n = B("n")
d = C("d")
j = D("j")
a = D("a")
e = A("e")
i = A("i")
b = B("b")
k = A("k")

g.o = d
g.v = b
n.w = b
n.r = d
n.z = d
d.z = n
j.x = n
a.x = n
e.o = d
e.v = n
i.o = d
i.v = b
b.w = n
b.r = d
b.z = d
k.o = d
k.v = b
assert e.v.r.z.w.w.z.z.r.z.txt == "n"