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

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

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

f = A("f")
n = B("n")
j = C("j")
c = C("c")

f.u = j
f.t = n
f.v = n
n.t = c
n.v = f
j.y = f
c.y = f
assert j.y.u.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: C = None
        self.t: B = None
        self.v: B = None
        self.txt = txt

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

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

f = A("f")
n = B("n")
j = C("j")
c = C("c")

f.u = j
f.t = n
f.v = n
n.t = c
n.v = f
j.y = f
c.y = f
assert j.y.u.y.t.txt == "n"