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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: A = None
        self.y: E = None
        self.v: D = None
        self.x: 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.r: D = None
        self.w: A = None
        self.x: F = None
        self.txt = txt

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

g = A("g")
m = B("m")
c = C("c")
d = D("d")
f = E("f")
i = F("i")
k = B("k")
n = C("n")
l = A("l")
h = E("h")

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

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

class C:
    def __init__(self, txt: str):
        self.s: E = None
        self.o: A = None
        self.y: E = None
        self.v: D = None
        self.x: 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.r: D = None
        self.w: A = None
        self.x: F = None
        self.txt = txt

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

g = A("g")
m = B("m")
c = C("c")
d = D("d")
f = E("f")
i = F("i")
k = B("k")
n = C("n")
l = A("l")
h = E("h")

g.r = i
m.z = l
m.q = g
c.s = f
c.y = f
c.o = l
c.x = l
c.v = d
d.p = i
f.r = d
f.w = g
f.x = i
i.x = g
i.y = k
k.z = g
k.q = g
n.s = f
n.o = g
n.y = h
n.v = d
n.x = l
l.r = i
h.r = d
h.w = g
h.x = i
assert h.r.p.y.txt == "k"