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

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

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

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

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

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

j = A("j")
f = B("f")
g = C("g")
b = D("b")
k = E("k")
n = F("n")

j.q = g
f.r = b
f.t = j
f.z = j
f.y = g
g.t = n
b.z = k
k.r = j
k.y = j
n.y = f
n.x = f
n.v = b
n.r = g
assert g.t.v.z.y.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.txt = txt

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

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

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

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

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

j = A("j")
f = B("f")
g = C("g")
b = D("b")
k = E("k")
n = F("n")

j.q = g
f.r = b
f.t = j
f.z = j
f.y = g
g.t = n
b.z = k
k.r = j
k.y = j
n.y = f
n.x = f
n.v = b
n.r = g
assert g.t.v.z.y.txt == "j"