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

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: D = None
        self.w: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: D = None
        self.p: B = None
        self.q: C = None
        self.txt = txt

j = A("j")
m = B("m")
b = C("b")
d = D("d")
e = E("e")
k = F("k")
g = B("g")
h = A("h")

j.p = k
j.u = k
m.r = g
m.q = d
m.v = h
m.s = k
m.z = k
b.r = m
b.t = d
b.w = g
d.s = h
e.z = j
e.u = b
e.y = h
k.y = b
k.q = b
k.z = d
k.p = g
g.r = m
g.q = d
g.v = j
g.s = k
g.z = k
h.p = k
h.u = k
assert j.p.p.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: F = None
        self.u: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.r: B = None
        self.t: D = None
        self.w: B = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.y: C = None
        self.z: D = None
        self.p: B = None
        self.q: C = None
        self.txt = txt

j = A("j")
m = B("m")
b = C("b")
d = D("d")
e = E("e")
k = F("k")
g = B("g")
h = A("h")

j.p = k
j.u = k
m.r = g
m.q = d
m.v = h
m.s = k
m.z = k
b.r = m
b.t = d
b.w = g
d.s = h
e.z = j
e.u = b
e.y = h
k.y = b
k.q = b
k.z = d
k.p = g
g.r = m
g.q = d
g.v = j
g.s = k
g.z = k
h.p = k
h.u = k
assert j.p.p.q.txt == "d"