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

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

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

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

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

a.v = d
a.u = d
a.o = h
a.x = g
d.o = j
d.p = j
d.r = j
j.t = d
j.r = d
j.q = g
j.s = m
g.q = d
m.o = j
m.p = j
m.r = j
h.v = m
h.u = m
h.o = a
h.x = g
assert a.u.o.r.r.r.o.txt == "
class A:
    def __init__(self, txt: str):
        self.v: B = None
        self.u: B = None
        self.o: A = None
        self.x: D = None
        self.txt = txt

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

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

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

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

a.v = d
a.u = d
a.o = h
a.x = g
d.o = j
d.p = j
d.r = j
j.t = d
j.r = d
j.q = g
j.s = m
g.q = d
m.o = j
m.p = j
m.r = j
h.v = m
h.u = m
h.o = a
h.x = g
assert a.u.o.r.r.r.o.txt == "j"