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

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

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

k = A("k")
l = B("l")
h = C("h")
f = C("f")

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

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

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

k = A("k")
l = B("l")
h = C("h")
f = C("f")

k.o = l
k.r = l
l.t = h
h.y = f
h.x = k
h.u = l
f.y = h
f.x = k
f.u = l
assert k.o.t.y.x.txt == "k"