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

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

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

b = A("b")
a = B("a")
h = C("h")
f = C("f")
c = A("c")
m = A("m")

b.y = h
b.x = c
a.o = h
h.w = m
h.t = f
h.s = f
f.w = c
f.t = h
f.s = h
c.y = h
c.x = m
m.y = h
m.x = c
assert a.o.w.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: C = None
        self.x: A = None
        self.txt = txt

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

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

b = A("b")
a = B("a")
h = C("h")
f = C("f")
c = A("c")
m = A("m")

b.y = h
b.x = c
a.o = h
h.w = m
h.t = f
h.s = f
f.w = c
f.t = h
f.s = h
c.y = h
c.x = m
m.y = h
m.x = c
assert a.o.w.y.txt == "h"