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

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

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

h = A("h")
c = B("c")
f = C("f")
d = B("d")
i = C("i")
a = B("a")

h.u = a
h.o = i
c.t = f
c.v = f
c.r = h
f.v = h
d.t = i
d.v = i
d.r = h
i.v = h
a.t = f
a.v = i
a.r = h
assert i.v.u.v.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.o: C = None
        self.txt = txt

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

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

h = A("h")
c = B("c")
f = C("f")
d = B("d")
i = C("i")
a = B("a")

h.u = a
h.o = i
c.t = f
c.v = f
c.r = h
f.v = h
d.t = i
d.v = i
d.r = h
i.v = h
a.t = f
a.v = i
a.r = h
assert i.v.u.v.txt == "i"