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

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

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

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

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

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

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

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

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

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

a.y = g
a.o = g
d.s = a
d.o = a
d.v = g
d.t = j
j.r = h
g.q = m
l.s = a
l.o = a
l.v = g
l.t = j
h.s = a
h.o = a
h.v = g
h.t = j
m.r = d
assert h.t.r.t.r.t.r.t.txt == "j"