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

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

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

m = A("m")
g = B("g")
i = C("i")
f = D("f")
b = E("b")
k = F("k")
l = E("l")
j = C("j")
a = F("a")
h = A("h")

m.q = b
m.x = h
g.x = a
i.p = b
f.r = h
f.z = g
b.s = a
k.r = i
k.z = a
l.s = a
j.p = l
a.r = i
a.z = k
h.q = l
h.x = m
assert j.p.s.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.x: A = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

class E:
    def __init__(self, txt: str):
        self.s: F = None
        self.txt = txt

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

m = A("m")
g = B("g")
i = C("i")
f = D("f")
b = E("b")
k = F("k")
l = E("l")
j = C("j")
a = F("a")
h = A("h")

m.q = b
m.x = h
g.x = a
i.p = b
f.r = h
f.z = g
b.s = a
k.r = i
k.z = a
l.s = a
j.p = l
a.r = i
a.z = k
h.q = l
h.x = m
assert j.p.s.z.r.txt == "i"