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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.v: E = None
        self.p: D = None
        self.w: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.z: F = None
        self.v: B = None
        self.o: F = None
        self.u: F = None
        self.x: A = None
        self.txt = txt

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

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

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

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

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

class B:
    def __init__(self, txt: str):
        self.q: D = None
        self.v: E = None
        self.p: D = None
        self.w: D = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.p: D = None
        self.z: F = None
        self.v: B = None
        self.o: F = None
        self.u: F = None
        self.x: A = None
        self.txt = txt

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

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

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

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

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