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

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: B = None
        self.z: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: B = None
        self.r: F = None
        self.t: D = None
        self.p: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: A = None
        self.p: C = None
        self.q: C = None
        self.txt = txt

h = A("h")
f = B("f")
b = C("b")
n = D("n")
i = E("i")
l = F("l")

h.r = n
f.z = b
b.v = f
b.x = f
b.z = n
n.x = l
i.o = h
i.y = f
i.p = f
i.r = l
i.t = n
l.o = b
l.p = b
l.q = b
l.y = h
assert f.z.v.z.x.txt == "
class A:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.v: B = None
        self.x: B = None
        self.z: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.x: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.o: A = None
        self.y: B = None
        self.r: F = None
        self.t: D = None
        self.p: B = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.o: C = None
        self.y: A = None
        self.p: C = None
        self.q: C = None
        self.txt = txt

h = A("h")
f = B("f")
b = C("b")
n = D("n")
i = E("i")
l = F("l")

h.r = n
f.z = b
b.v = f
b.x = f
b.z = n
n.x = l
i.o = h
i.y = f
i.p = f
i.r = l
i.t = n
l.o = b
l.p = b
l.q = b
l.y = h
assert f.z.v.z.x.txt == "f"