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

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

c = A("c")
f = B("f")
l = A("l")
a = B("a")
e = A("e")
h = B("h")
d = A("d")

c.w = d
f.o = a
f.r = h
l.w = d
a.o = f
a.r = f
e.w = c
h.o = f
h.r = f
d.w = c
assert h.o.r.r.o.o.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.w: A = None
        self.txt = txt

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

c = A("c")
f = B("f")
l = A("l")
a = B("a")
e = A("e")
h = B("h")
d = A("d")

c.w = d
f.o = a
f.r = h
l.w = d
a.o = f
a.r = f
e.w = c
h.o = f
h.r = f
d.w = c
assert h.o.r.r.o.o.r.r.txt == "f"