class A:
    def __init__(self, txt: str):
        self.r: 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.o: A = None
        self.v: A = None
        self.r: B = None
        self.txt = txt

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

f = A("f")
n = B("n")
i = C("i")
b = D("b")
l = A("l")
c = C("c")
e = B("e")
m = B("m")

f.r = l
n.y = l
i.o = f
i.v = l
i.r = m
b.q = i
b.x = c
b.t = l
l.r = f
c.o = f
c.v = l
c.r = m
e.y = f
m.y = l
assert f.r.r.r.r.txt == "
class A:
    def __init__(self, txt: str):
        self.r: 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.o: A = None
        self.v: A = None
        self.r: B = None
        self.txt = txt

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

f = A("f")
n = B("n")
i = C("i")
b = D("b")
l = A("l")
c = C("c")
e = B("e")
m = B("m")

f.r = l
n.y = l
i.o = f
i.v = l
i.r = m
b.q = i
b.x = c
b.t = l
l.r = f
c.o = f
c.v = l
c.r = m
e.y = f
m.y = l
assert f.r.r.r.r.txt == "f"