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

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

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

a = A("a")
j = B("j")
b = C("b")
f = B("f")
h = C("h")
n = C("n")

a.y = j
j.y = a
j.u = n
j.w = f
b.w = a
b.x = n
b.v = n
f.y = a
f.u = b
f.w = j
h.w = a
h.x = n
h.v = b
n.w = a
n.x = h
n.v = b
assert j.y.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.y: B = None
        self.txt = txt

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

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

a = A("a")
j = B("j")
b = C("b")
f = B("f")
h = C("h")
n = C("n")

a.y = j
j.y = a
j.u = n
j.w = f
b.w = a
b.x = n
b.v = n
f.y = a
f.u = b
f.w = j
h.w = a
h.x = n
h.v = b
n.w = a
n.x = h
n.v = b
assert j.y.y.u.txt == "n"