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

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

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

k = A("k")
b = B("b")
h = C("h")
n = B("n")
e = B("e")
c = A("c")
d = B("d")

k.y = c
b.y = c
h.r = k
n.y = c
e.y = c
c.y = k
d.y = c
assert h.r.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

k = A("k")
b = B("b")
h = C("h")
n = B("n")
e = B("e")
c = A("c")
d = B("d")

k.y = c
b.y = c
h.r = k
n.y = c
e.y = c
c.y = k
d.y = c
assert h.r.y.y.txt == "k"