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

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

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

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

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

a.v = b
a.t = b
a.p = j
h.s = c
h.o = c
h.t = g
h.z = d
c.u = d
c.z = j
c.o = j
c.y = a
g.v = b
b.v = g
d.s = c
d.o = c
d.t = b
d.z = h
j.u = d
j.z = c
j.o = c
j.y = a
assert d.t.v.v.v.v.v.v.txt == "
class A:
    def __init__(self, txt: str):
        self.v: D = None
        self.p: C = None
        self.t: D = None
        self.txt = txt

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

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

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

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

a.v = b
a.t = b
a.p = j
h.s = c
h.o = c
h.t = g
h.z = d
c.u = d
c.z = j
c.o = j
c.y = a
g.v = b
b.v = g
d.s = c
d.o = c
d.t = b
d.z = h
j.u = d
j.z = c
j.o = c
j.y = a
assert d.t.v.v.v.v.v.v.txt == "b"