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

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

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

h = A("h")
k = B("k")
l = C("l")
a = B("a")
d = C("d")

h.x = a
k.o = a
k.u = a
k.r = h
l.v = k
a.o = k
a.u = k
a.r = h
d.v = k
assert a.r.x.o.o.r.txt == "
class A:
    def __init__(self, txt: str):
        self.x: B = None
        self.txt = txt

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

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

h = A("h")
k = B("k")
l = C("l")
a = B("a")
d = C("d")

h.x = a
k.o = a
k.u = a
k.r = h
l.v = k
a.o = k
a.u = k
a.r = h
d.v = k
assert a.r.x.o.o.r.txt == "h"