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

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

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

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

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

l.v = j
l.o = b
d.x = e
d.u = e
d.z = b
g.p = b
b.q = j
b.o = j
b.t = g
b.v = g
j.v = l
j.o = b
a.p = b
e.x = d
e.u = d
e.z = b
h.p = b
assert h.p.v.p.o.v.o.v.p.txt == "
class A:
    def __init__(self, txt: str):
        self.v: A = None
        self.o: D = None
        self.txt = txt

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

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

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

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

l.v = j
l.o = b
d.x = e
d.u = e
d.z = b
g.p = b
b.q = j
b.o = j
b.t = g
b.v = g
j.v = l
j.o = b
a.p = b
e.x = d
e.u = d
e.z = b
h.p = b
assert h.p.v.p.o.v.o.v.p.txt == "b"