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

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

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

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

a = A("a")
d = B("d")
k = C("k")
h = D("h")
b = D("b")
g = C("g")
j = B("j")
l = B("l")

a.z = l
a.r = h
d.v = k
d.o = a
k.s = d
k.w = g
k.x = a
k.q = l
h.o = d
b.o = l
g.s = j
g.w = k
g.x = a
g.q = d
j.v = g
j.o = a
l.v = g
l.o = a
assert b.o.o.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.r: D = None
        self.txt = txt

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

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

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

a = A("a")
d = B("d")
k = C("k")
h = D("h")
b = D("b")
g = C("g")
j = B("j")
l = B("l")

a.z = l
a.r = h
d.v = k
d.o = a
k.s = d
k.w = g
k.x = a
k.q = l
h.o = d
b.o = l
g.s = j
g.w = k
g.x = a
g.q = d
j.v = g
j.o = a
l.v = g
l.o = a
assert b.o.o.r.o.txt == "d"