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

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

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

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

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

b.y = h
h.t = f
h.v = f
h.o = d
f.r = e
j.q = h
e.y = h
d.t = f
d.o = h
d.v = a
a.r = b
assert e.y.o.o.o.v.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

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

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

b.y = h
h.t = f
h.v = f
h.o = d
f.r = e
j.q = h
e.y = h
d.t = f
d.o = h
d.v = a
a.r = b
assert e.y.o.o.o.v.txt == "a"