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

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: F = None
        self.x: G = None
        self.u: A = None
        self.txt = txt

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: A = None
        self.z: F = None
        self.p: C = None
        self.y: E = None
        self.q: F = None
        self.r: C = None
        self.txt = txt

f = A("f")
h = B("h")
d = C("d")
j = D("j")
n = E("n")
c = F("c")
l = G("l")
i = F("i")

f.x = i
f.o = i
h.o = d
h.r = c
h.x = l
h.u = f
d.z = f
j.p = c
n.z = j
n.r = j
n.w = j
n.x = f
c.w = f
l.o = h
l.x = f
l.z = c
l.p = d
l.r = d
l.y = n
l.q = i
i.w = f
assert f.o.w.x.w.o.w.txt == "
class A:
    def __init__(self, txt: str):
        self.x: F = None
        self.o: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: C = None
        self.r: F = None
        self.x: G = None
        self.u: A = None
        self.txt = txt

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

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

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

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

class G:
    def __init__(self, txt: str):
        self.o: B = None
        self.x: A = None
        self.z: F = None
        self.p: C = None
        self.y: E = None
        self.q: F = None
        self.r: C = None
        self.txt = txt

f = A("f")
h = B("h")
d = C("d")
j = D("j")
n = E("n")
c = F("c")
l = G("l")
i = F("i")

f.x = i
f.o = i
h.o = d
h.r = c
h.x = l
h.u = f
d.z = f
j.p = c
n.z = j
n.r = j
n.w = j
n.x = f
c.w = f
l.o = h
l.x = f
l.z = c
l.p = d
l.r = d
l.y = n
l.q = i
i.w = f
assert f.o.w.x.w.o.w.txt == "f"