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

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

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

n = A("n")
d = B("d")
k = C("k")
h = C("h")

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

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

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

n = A("n")
d = B("d")
k = C("k")
h = C("h")

n.o = d
d.u = k
d.y = h
k.u = n
k.x = d
k.v = d
h.u = n
h.x = d
h.v = d
assert n.o.u.u.o.txt == "d"